home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
5
/
CHASSIS_
/
TEXTWIND.C
< prev
next >
Wrap
Text File
|
1992-05-14
|
4KB
|
140 lines
/************************************************************************************/
/* TextWindowProc */
/************************************************************************************/
#include "MyHeaders.h"
int TextWindowProc()
{
int TextWindRetCode = 0;
int workPart;
int h,v;
Rect sizeRect;
ControlHandle workControlHandle;
SetPort (windTbl[windSub].windPtr); /* set as the grafPort */
TEIdle (windTbl[windSub].windTEH[0]);
workPoint = myEvent.where;
GlobalToLocal(&workPoint);
switch (myEvent.what) /* how did I get here? */
{
case (mouseDown): /* MouseDown? */
switch (myMouseWhere) /* What part of window? */
{
case (inContent): /* content region: */
workPart = FindControl (workPoint, /* check for control */
windTbl[windSub].windPtr,
&workControlHandle);
if (workPart) /* if so, track it */
{
if (workPart != inThumb) /* if not in thumb: use my proc */
/* to scroll and reset thumb */
/* on the basis of the scroll */
TrackControl (workControlHandle, workPoint, (ProcPtr) -1);
else /* in thumb: use native routine */
{ /* then invoke my proc to */
/* scroll on the basis of thumb */
k = GetCtlValue (workControlHandle);
TrackControl (workControlHandle, workPoint, NIL);
k -= GetCtlValue (workControlHandle);
myActionProc(workControlHandle, (short) workPart);
}
}
else
if ( PtInRect(workPoint,
&(**windTbl[windSub].windTEH[0]).viewRect) )
{
if ( BitAnd(myEvent.modifiers, shiftKey) )
TEClick(workPoint, TRUE, windTbl[windSub].windTEH[0]);
else
TEClick(workPoint, FALSE, windTbl[windSub].windTEH[0]);
WorkRetCode = MenuUpdate(ProcText); /* reset menus */
}
break;
case (inDrag): /* drag region: */
DragWindow (windTbl[windSub].windPtr,
myEvent.where, &myDragRect);
break;
case (inZoomIn):
case (inZoomOut):
workBoolean = TrackBox (windTbl[windSub].windPtr,
myEvent.where, myMouseWhere);
if (workBoolean)
{
ZoomWindow (windTbl[windSub].windPtr,
myMouseWhere, TRUE);
WorkRetCode = TextResizeProc();
}
break;
case (inGrow): /* grow region: */
SetRect (&sizeRect, 160,84,1200,900); /* limits for grow size */
worklong = GrowWindow (windTbl[windSub].windPtr,
myEvent.where, &sizeRect);
if (worklong) /* if size changedâ•”*/
{
v = HiWord(worklong);
h = LoWord(worklong);
SizeWindow (windTbl[windSub].windPtr, h, v, TRUE);
WorkRetCode = TextResizeProc();
}
break;
case (inGoAway): /* goaway region: */
if (TrackGoAway (windTbl[windSub].windPtr, myEvent.where))
WorkRetCode = TextCloseProc();
break;
}
break;
case(autoKey):
case(keyDown):
workChar = (char) BitAnd(myEvent.message, charCodeMask);
workTEHandle = windTbl[windSub].windTEH[0]; /* get handle */
if ((((**workTEHandle).teLength /* if there's no room */
+ (**workTEHandle).selStart
- (**workTEHandle).selEnd) >= 32767)
&& (workChar != '\b')) /* and not a backspace */
{
PlaceAlert (133);
StopAlert (133, NIL); /* stop it */
}
else
{ /* otherwise */
TEKey (workChar, windTbl[windSub].windTEH[0]); /* accept char */
windTbl[windSub].windTEChanged = TRUE; /* mark changed */
myActionProc (windTbl[windSub].windCntlH[0], 0); /* rescroll */
WorkRetCode = MenuUpdate(ProcText); /* update menus */
}
break;
case (activateEvt):
DrawGrowIcon (windTbl[windSub].windPtr); /* draw grow icon and lines */
j = (int) BitAnd(myEvent.modifiers, activeFlag);
if (j) /* if activate... */
{
WorkRetCode = MenuUpdate(ProcText); /* set menus */
TEActivate (windTbl[windSub].windTEH[0]); /* hilite */
HiliteControl (windTbl[windSub].windCntlH[0], 0);
}
else /* if deactivate... */
{
TEDeactivate (windTbl[windSub].windTEH[0]);
HiliteControl (windTbl[windSub].windCntlH[0], 255); /* unhilite */
}
break;
}
return TextWindRetCode;
}